<!DOCTYPE html>
<html lang="en">
<head>
  <title>array events table</title>
  <meta charset="utf-8"/>
  <script src="../../dist/jsoneditor.js"></script>
</head>
<body>

<h1>Test</h1>
<label for="debug">Value</label>
<textarea id="debug" class="debug" cols="30" rows="10"></textarea>
<button class='get-value'>Get Value</button>
<div class='container'></div>

<script>
  const container = document.querySelector('.container');
  const debug = document.querySelector('.debug');
  const schema = {
    "type": "array",
    "title": "Strings",
    "format": "table",
    "items": {
      "type": "string",
      "title": "String"
    }
  };

  const editor = new JSONEditor(container, {
    schema: schema,
    enable_array_copy: true
  });

  editor.promise.then(() => {
    document.querySelector('.get-value').addEventListener('click', function () {
      debug.value = JSON.stringify(editor.getValue());
    });

    editor.setValue(["A", "B", "C", "D", "E"]);

    editor.on('copyRow', function () {
      alert('copyRow');
      console.log('copyRow');
    });

    editor.on('moveRow', function () {
      alert('moveRow');
      console.log('moveRow');
    });

    editor.on('addRow', function () {
      alert('addRow');
      console.log('addRow');
    });

    editor.on('deleteRow', function () {
      alert('deleteRow');
      console.log('deleteRow');
    });

    editor.on('deleteAllRows', function () {
      alert('deleteAllRows');
      console.log('deleteAllRows');
    });
  })

</script>

</body>
</html>
